<template>
	
	
	<u-popup mode="center" v-model="show" borderRadius="20" closeable @close="close">
		<view class="pop p30">
			<view class="title f32 c3 bold mb30 t-flex center">师傅信息完善</view>
			
			<view class="li t-flex between mb30">
				<view class="c6">
					完成认证
				</view>
				<view class="btn" @click="$go('/pages/authentication/form')" v-if="!status[0]">
					去完成
				</view>
				<view class="mainC f24" v-else>
					已认证<text class="iconfont icon-duihao ml20"></text>
				</view>
			</view>
			
			<view class="li t-flex between mb30" >
				<view class="c6">
					添加车辆
				</view>
				<view class="btn" v-if="!status[1]" @click="$go('/pages/workerClient/myCar/myCar')">
					去添加
				</view>
				<view class="mainC f24" v-else>
					已添加<text class="iconfont icon-duihao ml20"></text>
				</view>
			</view>
			
			<view class="li t-flex between mb30"  >
				<view class="c6">
					设置我的可预约时间
				</view>
				<view class="btn" v-if="!status[2]" @click="$go('/pages/workerClient/schedule/schedule')">
					去设置
				</view>
				<view class="mainC f24" v-else>
					已设置<text class="iconfont icon-duihao ml20"></text>
				</view>
			</view>
			
			<view class="li t-flex between mb30" >
				<view class="c6">
					设置我的服务区域
				</view>
				<view class="btn" v-if="!status[3]" @click="$go('/pages/workerClient/servers/servers')">
					去设置
				</view>
				<view class="mainC f24" v-else>
					已设置<text class="iconfont icon-duihao ml20"></text>
				</view>
			</view>
			
			<view class="rule t-flex center pt30">
				<u-checkbox 
				v-model="readed"
				active-color="#F98306"
				shape="circle"
				>
					<text class="ml10">不再提醒</text>
				</u-checkbox>
			</view>
		</view>
	</u-popup>
	
	
	
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useStore } from '../../store';
import { getTime, tRequest } from '../../lib/ts/util';
import { getSfTime, indexSfServiceQy } from '../../api';
	
	const store = useStore()
	let show = ref(false)
	let readed = ref(false)
	let status = ref([])
	
	const init = async ()=>{
		let readed = uni.getStorageSync('readed')
		if(readed) return
		let arr = [false,false,false,false]
		if(store.userinfo.sf_rz_status) arr[0] = true
		let carres = await getMycar()
		if(carres.length) arr[1] = true
		let now = +new Date()
		let end = getTime((now+(86400000*10))/1000 ,2)
		let start = getTime(now/1000,2)
		let timeres = await getSfTime({user_id:store.userinfo.id,s_day:start,e_day:end})
		if(timeres.length) arr[2] = true
		let cityres = await indexSfServiceQy()
		if(cityres) arr[3] = true
		
		
		status.value = arr
		console.log(arr,'?')
		if(arr.includes(false) && !readed){
			show.value = true
		}else{
			show.value = false
			uni.setStorageSync('readed',1)
		}
	}
	
	
	
	
	//获取我的车辆
	const getMycar = async ()=>{
		let res = await tRequest('post','/api/user/MyCarList',{page:1,limit:1})
		return res.data
	}
	
	const close = ()=>{
		if(readed.value){
			uni.setStorageSync('readed',1)
		}
	}
	
	defineExpose({
		init
	})
	
</script>

<style scoped lang="scss">
	.pop{
		width: 600rpx;
		.btn{
			background-color: $main-color;
			color: #fff;
			border-radius: 10rpx;
			padding: 10rpx 20rpx;
			font-size: 24rpx;
		}
		.li{
			padding: 10rpx 0;
		}
	}
	

</style>